package com.cloudm.technician.data.model

import android.os.Parcel
import android.os.Parcelable

/**
 * 作者: wesley
 * 时间: 2017/12/13
 * 描述: 设备的实体类
 *
 * deviceName: 设备名称
 * type: 设备类型
 * typeId: 类型id
 * brand: 设备品牌
 * brandId: 品牌id
 * model: 设备型号
 * modelId: 型号id
 * rackId: 几号
 * license: 车牌号
 * factoryTime: 出厂年份
 * workTime: 工作时长
 */
data class DeviceInfo(var id: Int?, var deviceName: String?, var type: String?, var typeId: Int?,
                      var brand: String?, var brandId: Int?, var model: String?, var modelId: Int?,
                      var rackId: String?, var workTime: String?, var createTime: String?,
                      var status: Int, var license: String?, var factoryTime: String?,
                      var transferTime: String?, var nickname: String?, var mobile: String?,
                      var sn: String?, var recordId: String?, val deviceId: Int?,
                      val gmtCreate: String?) : Parcelable {

    constructor(parcel: Parcel) : this(parcel.readValue(Int::class.java.classLoader) as? Int,
            parcel.readString(), parcel.readString(),
            parcel.readValue(Int::class.java.classLoader) as? Int, parcel.readString(),
            parcel.readValue(Int::class.java.classLoader) as? Int, parcel.readString(),
            parcel.readValue(Int::class.java.classLoader) as? Int, parcel.readString(),
            parcel.readString(), parcel.readString(), parcel.readInt(), parcel.readString(),
            parcel.readString(), parcel.readString(), parcel.readString(), parcel.readString(),
            parcel.readString(), parcel.readString(),
            parcel.readValue(Int::class.java.classLoader) as? Int, parcel.readString())

    override fun writeToParcel(parcel: Parcel, flags: Int) {
        parcel.writeValue(id)
        parcel.writeString(deviceName)
        parcel.writeString(type)
        parcel.writeValue(typeId)
        parcel.writeString(brand)
        parcel.writeValue(brandId)
        parcel.writeString(model)
        parcel.writeValue(modelId)
        parcel.writeString(rackId)
        parcel.writeString(workTime)
        parcel.writeString(createTime)
        parcel.writeInt(status)
        parcel.writeString(license)
        parcel.writeString(factoryTime)
        parcel.writeString(transferTime)
        parcel.writeString(nickname)
        parcel.writeString(mobile)
        parcel.writeString(sn)
        parcel.writeString(recordId)
        parcel.writeValue(deviceId)
        parcel.writeString(gmtCreate)
    }

    override fun describeContents(): Int {
        return 0
    }

    companion object CREATOR : Parcelable.Creator<DeviceInfo> {
        override fun createFromParcel(parcel: Parcel): DeviceInfo {
            return DeviceInfo(parcel)
        }

        override fun newArray(size: Int): Array<DeviceInfo?> {
            return arrayOfNulls(size)
        }
    }


}